package com.corticon.dialogs.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * Message entity.
 * 
 * @author heweiya
 */
@Entity
@Table(name = "message")
public class Message implements Serializable {

    private Long messageId;
    private String key;
    private String value;
    private Language language;

    public Message() {
    }

    // Property accessors
    @Id
    @SequenceGenerator(name = "messageid_seq",
                       sequenceName = "messageid_seq",
                       allocationSize = 1, initialValue = 1) // Set allocationSize and initialValue
                                                             // to let sequence increment following DB.
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "messageid_seq")
    @Column(name = "messageid",  nullable = false, columnDefinition = "integer")
    public Long getMessageId() {
        return this.messageId;
    }

    public void setMessageId(Long messageId) {
        this.messageId = messageId;
    }

    @Column(name = "messagekey", length = 256)
    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    @Column(name = "messageinfo", length = 1000)
    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "languageassoc_code_oid", insertable = false, updatable = false)
    public Language getLanguage() {
        return language;
    }

    public void setLanguage(Language language) {
        this.language = language;
    }
}